<%@page import="java.util.LinkedHashMap"%>
<%@page import="java.util.Set"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="com.baozun.model.TChatEx"%>
<%@page import="com.baozun.model.TFriend"%>
<%@page import="com.baozun.util.items.SelectSet"%>
<%@page import="com.baozun.util.StringUtil"%>
<%@page import="com.baozun.model.TUser"%>
<%@page import="com.baozun.util.PageData"%>
<%@page import="com.baozun.util.CommonConst"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Static &amp; Dynamic Tables" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- basic styles -->

<link href="../assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="../assets/css/font-awesome.min.css" />
<link rel="stylesheet" href="../assets/css/font.css" />

<link rel="stylesheet" href="../assets/css/ace.min.css" />
<link rel="stylesheet" href="../assets/css/ace-rtl.min.css" />
<link rel="stylesheet" href="../assets/css/ace-skins.min.css" />

<script src="../assets/js/ace-extra.min.js"></script>
<style>
.page-header{
	padding-top:1px;
	padding-bottom:2px;
}

.table thead tr{
	background: #307ecc;
	color: #ffffff;
}
</style>
</head>
<%
TUser user = (TUser)session.getAttribute(CommonConst.SESSION_USER);
LinkedHashMap<String, TChatEx> chatExMap = (LinkedHashMap<String, TChatEx>)request.getAttribute("chatExMap");
%>
<body>
	<div class="page-content">
		<div class="page-header">
			<h5>
				聊天记录
			</h5>
		</div>
		<!-- /.page-header -->
		<div class="row">
			<div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
				<div class="row">
					<div class="col-xs-12">
						<div class="table-responsive">
							<table id="sample-table-1"
								class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">姓名</th>
										<th class="center">备注</th>
										<th class="center">时间</th>
										<th class="center">内容</th>
										<th class="center">操作</th>
									</tr>
								</thead>
								<tbody>
								<%
								Set<Entry<String,TChatEx>> set = chatExMap.entrySet();
								Iterator<Entry<String,TChatEx>> ite = set.iterator();
								while(ite.hasNext()){
								    Entry<String, TChatEx> entry = ite.next();
								    String stChatId = entry.getKey();
								    TChatEx chatEx = entry.getValue();
								    %>
								    <tr>
										<td class="center"><%=StringUtil.param2Html(chatEx.getStName()) %></td>
										<td class="center"><%=StringUtil.param2Html(chatEx.getStRemark()) %></td>
										<td class="center"><%=StringUtil.param2Html(chatEx.getDtTime(),"yyyy-MM-dd HH:mm:ss") %></td>
										<td class="center"><%=StringUtil.param2Html(chatEx.getStChatContent()) %></td>
										<td class="center" style="width:15%">
											<div>
												<button class="btn btn-xs btn-pink" title="开始聊天">
													<i class=" icon-comments-alt bigger-120"></i>
												</button>
												<button class="btn btn-xs btn-danger" onclick="deleteChat('<%=stChatId%>')">
													<i class="icon-trash bigger-120"></i>
												</button>
											</div>
										</td>
									</tr>
								    <%
								    }
								%>
									
								</tbody>
							</table>
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /span -->
				</div>
				<!-- /row -->
			</div>
			<!-- /.col -->
		</div>
		<!-- /.row -->
	</div>
	<!-- /.page-content -->
	<script type="text/javascript" src="../assets/js/jquery-2.0.3.min.js"></script>
	<script type="text/javascript" src="../js/artDialog/artDialog.source.js?skin=default"></script>
	<script type="text/javascript" src="../js/artDialog/plugins/iframeTools.source.js"></script>
	<script type="text/javascript" src="../js/openDialog.js"></script>
	<script type="text/javascript" src="../js/openDialogcustom.js"></script>
	<script type="text/javascript">
$(document).ready(function(){
    window.iframeResize = function(){  
        var  dvalue = 0;  
       // if($.browser.safari){  
       //     dvalue = 67; 
       // }  
        parent.document.getElementById("chat_iframe").scrolling = "yes";  
        parent.document.getElementById("chat_iframe").height = "";  
        parent.document.getElementById("chat_iframe").style.height = "";  
        parent.document.getElementById("chat_iframe").height = document.body.scrollHeight + dvalue;  
      };
      if(window.iframeResize){  
          window.iframeResize();  
      }
      parent.iFrameHeight();
});
function pagechange(page){
	parent.document.contact_search_form.currentPage.value=page;
	process();
}

//刷新查询
function process(){
	parent.document.contact_search_form.submit();
}
//删除
function deleteContact(id){
	if(confirm("确认删除此好友聊天记录吗?")){
		$.ajax({
			url:'chat_delete',
			data:{stContactId:id},
			dataType:"text",
			type:"post",
			success:function(data,status){
				if("right" == data){
					process();
				}else{
					alert("删除失败！");
				}
			}	
	});
	}
}
</script>
</body>
</html>